package com.wa.graphql.enums;

import com.wa.graphql.scalar.GraphQLDate;
import graphql.Scalars;
import graphql.schema.GraphQLScalarType;

import java.util.HashMap;
import java.util.Map;

/**
 * <p>对象类型枚举</p>
 * <p> aaron.qiu </p>
 * <p>Version: 1.0.0</p>
 * <p>Create Date： 2018-11-07 19:42:37 </p>
 * <p>Copyright (c) 2018 ~ 2019 Allchips版权所有</p>
 */
public enum ObjectTypeEnum {
    //java对象类型枚举
    SHORT("java.lang.Short", Scalars.GraphQLShort),
    Integer("java.lang.Integer", Scalars.GraphQLInt),
    Long("java.lang.Long", Scalars.GraphQLLong),
    FLOAT("java.lang.Float", Scalars.GraphQLFloat),
    DOUBLE("java.lang.Double", Scalars.GraphQLFloat),
    BigDecimal("java.math.BigDecimal", Scalars.GraphQLBigDecimal),
    Boolean("java.lang.Boolean", Scalars.GraphQLBoolean),
    Byte("java.lang.Byte", Scalars.GraphQLByte),
    Character("java.lang.Character", Scalars.GraphQLChar),
    String("java.lang.String", Scalars.GraphQLString),
    Date("java.util.Date", new GraphQLDate()),
    BASIC_SHORT("short", Scalars.GraphQLShort),
    BASIC_BYTE("byte", Scalars.GraphQLByte),
    BASIC_ChAR("char", Scalars.GraphQLChar),
    BASIC_INT("int", Scalars.GraphQLInt),
    BASIC_LONG("long", Scalars.GraphQLLong),
    BASIC_FLOAT("float", Scalars.GraphQLFloat),
    BASIC_DOUBLE("double", Scalars.GraphQLBigDecimal),
    BASIC_BOOLEAN("boolean", Scalars.GraphQLBoolean);


    //状态英文
    private String statusMsgEn;
    //状态中文
    private GraphQLScalarType scalarType;

    // Reverse-lookup map for getting a day from an abbreviation
    private static final Map<String, ObjectTypeEnum> lookup = new HashMap<>();

    static {
        for (ObjectTypeEnum ase : ObjectTypeEnum.values()) {
            lookup.put(ase.statusMsgEn, ase);
        }
    }

    private ObjectTypeEnum(String statusMsgEn, GraphQLScalarType scalarType) {
        this.statusMsgEn = statusMsgEn;
        this.scalarType = scalarType;
    }


    public String getStatusMsgEn() {
        return statusMsgEn;
    }

    public GraphQLScalarType getScalarType() {
        return scalarType;
    }

    public static ObjectTypeEnum getScalarType(String objectTypeName) {
        return lookup.get(objectTypeName);
    }
}
